package doru;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;


  	  public class ColorCells extends DefaultTableCellRenderer {
      TableCellRenderer renderer;
      
  	      public ColorCells(JTable table) {
      renderer = table.getTableHeader().getDefaultRenderer();
      }
      
      public Component getTableCellRendererComponent(JTable table, Object value,
  	          boolean isSelected, boolean hasFocus, int row, int column) {
      Component c = super.getTableCellRendererComponent(table, value,
          isSelected, hasFocus, row, column);
      
      
      String cellContents = (String) value;
      if (value == null) return c;
     
      if (cellContents.contains("Malicious") | (cellContents.contains("blocked"))) {
        c.setBackground(Color.red);
        
      }
      if (cellContents.contains("Clean")) {
          c.setBackground(Color.green); 
      }
      if(cellContents.contains("Already")) {
    	  c.setBackground(Color.yellow);
      }
      if(cellContents.contains(" ")){
    	  c.setBackground(Color.white);
      }
      
  return c;
    }
 }

